#Include "Protheus.ch"

User Function TstBrw()

Local cTitulo    := OemToAnsi(">>>> Monitoramento das Vendas <<<<<")
Local oDlg       := Nil
Local oLbx1      := Nil
Local oLbx2      := Nil
Local oLbx3      := Nil

Private aMetas     := {}
Private aCliAtend  := {}
Private aCliNaoAte := {}

DEFINE MSDIALOG oDlg TITLE cTitulo FROM 0000, 0000 TO 0711, 1378 OF GetWndDefault() PIXEL
oDlg:lEscClose  := .F. // Nao permite sair ao se pressionar a tecla ESC.
oDlg:lMaximized := .T.
@ 020, 010 LISTBOX oLbx1 FIELDS HEADER "Periodo Inic.", "Periodo Fin.","Vendas Mensais","Valor Meta Mensal","% Vendas","Status" SIZE 410,060 OF oDlg PIXEL ON CHANGE EVal({||Troca(aMetas[oLbx1:nAt, 1]), oLbx2:Refresh()})
AAdd(aMetas, {CToD("01/03/2014"), CToD("03/30/2014"), 38348.20, 70000.00, 54.78, 0})
AAdd(aMetas, {CToD("01/04/2014"), CToD("04/30/2014"), 4215.28, 100000.00, 4.21, 0})
oLbx1:SetArray(aMetas)
oLbx1:bLine := {|| aMetas[oLbx1:nAt]}

@ 090, 010 LISTBOX oLbx2 FIELDS HEADER "Codigo","Cliente","Cidade","Uf","Status" SIZE 410,070 OF oDlg PIXEL //ON CHANGE ChangeAVet1()
AAdd(aCliAtend, {StrZero(10, 10), "DANTAS E AMARAL PRODUTOS NATURAIS LTDA M", "ARACAJU", "UF", 0})
AAdd(aCliAtend, {StrZero(10, 06), "FS COMERCIO DE MEDICAMENTOS LTDA", "VARZEA GRANDE", "SP", 0})
oLbx2:SetArray(aCliAtend)
oLbx2:bLine := {|| aCliAtend[oLbx2:nAt]}

@ 170, 010 LISTBOX oLbx3 FIELDS HEADER "Codigo","Cliente","Cidade","Uf","Ult.Compra","Status" SIZE 250,070 OF oDlg PIXEL //ON CHANGE ChangeAVet1()
ACTIVATE MSDIALOG oDlg /*ON INIT EnchoiceBar(oDlg, bOk, bCancel, .F., @aButtons)*/ CENTERED

Return Nil

Static Function Troca(dDatIni)

aCliAtend := {}

IF dDatIni == CToD("01/03/2014")
	AAdd(aCliAtend, {StrZero(10, 10), "DANTAS E AMARAL PRODUTOS NATURAIS LTDA M", "ARACAJU", "UF", 0})
	AAdd(aCliAtend, {StrZero(06, 10), "FS COMERCIO DE MEDICAMENTOS LTDA", "VARZEA GRANDE", "SP", 0})
Else
	AAdd(aCliAtend, {StrZero(62, 10), "FS COMERCIO DE MEDICAMENTOS LTDA", "VARZEA GRANDE", "SP", 0})
	AAdd(aCliAtend, {StrZero(67, 10), "RB DROGARIA LTDA ME", "PARAUNA", "SP", 0})
EndIF

Return Nil